"""
检查数据库表结构
"""
from sqlalchemy import create_engine, text
from config import settings

def check_table_structure():
    """检查数据库表结构"""
    # 创建数据库引擎
    engine = create_engine(settings.database_url)
    
    with engine.begin() as conn:
        try:
            print("=== email_configs表结构 ===")
            result = conn.execute(text("SHOW COLUMNS FROM email_configs"))
            for row in result:
                print(f"字段: {row[0]}, 类型: {row[1]}, 是否为空: {row[2]}, 键: {row[3]}, 默认值: {row[4]}")
            
            print("\n=== data_sources表结构 ===")
            result = conn.execute(text("SHOW COLUMNS FROM data_sources"))
            for row in result:
                print(f"字段: {row[0]}, 类型: {row[1]}, 是否为空: {row[2]}, 键: {row[3]}, 默认值: {row[4]}")
                
        except Exception as e:
            print(f"检查表结构失败: {e}")

if __name__ == "__main__":
    check_table_structure()
